package cn.stylefeng.guns.modular.recy.controller;
/*
 */

import cn.stylefeng.roses.core.base.controller.*;
import org.springframework.stereotype.*;
import cn.stylefeng.guns.modular.recy.service.*;
import org.springframework.beans.factory.annotation.*;
import cn.stylefeng.roses.core.reqres.response.*;
import cn.stylefeng.guns.modular.recy.entity.*;
import java.io.*;
import cn.stylefeng.guns.core.common.page.*;
import com.baomidou.mybatisplus.core.metadata.*;
import com.baomidou.mybatisplus.core.conditions.*;
import cn.stylefeng.guns.modular.recy.vo.*;
import cn.stylefeng.guns.modular.recy.utils.*;
import cn.hutool.core.bean.*;
import java.util.stream.*;
import cn.stylefeng.guns.modular.recy.warpper.*;
import com.baomidou.mybatisplus.core.conditions.query.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.*;
import java.util.*;
import org.springframework.web.bind.annotation.*;
import org.springframework.ui.*;

@Controller
@RequestMapping({ "/appVersionInfo" })
public class AppVersionInfoController extends BaseController
{
    private String PREFIX;
    @Autowired
    private AppVersionInfoService appVersionInfoService;
    
    public AppVersionInfoController() {
        this.PREFIX = "/modular/recy/appVersionInfo/";
    }
    
    @RequestMapping({ "" })
    public String index() {
        return this.PREFIX + "appVersionInfo.html";
    }
    
    @RequestMapping({ "/add" })
    public String appVersionInfoAdd() {
        //添加版本更新
        return this.PREFIX + "appVersionInfo_add.html";
    }
    
    @RequestMapping({ "/edit" })
    public String appVersionInfoUpdate(@RequestParam("id") final String id) {
        return this.PREFIX + "appVersionInfo_edit.html";
    }
    
    @RequestMapping({ "/detail/{id}" })
    @ResponseBody
    public ResponseData detail(@PathVariable final String id) {
        System.out.println();
        final AppVersionInfo appVersionInfo = (AppVersionInfo)this.appVersionInfoService.getById((Serializable)id);
        return (ResponseData)ResponseData.success(appVersionInfo);
    }
    
    @RequestMapping({ "/list" })
    @ResponseBody
    public Object list(final AppVersionInfo appVersionInfoQuery) {
        final QueryWrapper<AppVersionInfo> appVersionInfoQueryWrapper = ControllerUtil.createQuery(appVersionInfoQuery, this.getHttpServletRequest());
        final Page<AppVersionInfo> page = (Page<AppVersionInfo>)LayuiPageFactory.defaultPage();
        final IPage<AppVersionInfo> page2 = (IPage<AppVersionInfo>)this.appVersionInfoService.page((IPage)page, (Wrapper)appVersionInfoQueryWrapper);
        final List<AppVersionInfoVO> appVersionInfoVOList = EntityBind.bind(page2.getRecords(), AppVersionInfoVO.class);
        final List<Map<String, Object>> list = appVersionInfoVOList.stream().map(appVersionInfo -> BeanUtil.beanToMap(appVersionInfo)).collect(Collectors.toList());
        page2.setRecords((List)new AppVersionInfoWrapper(list).wrap());
        return LayuiPageFactory.createPageInfo(page2);
    }
    
    @RequestMapping({ "/addItem" })
    @ResponseBody
    public Object add(final AppVersionInfo appVersionInfo) {
        this.appVersionInfoService.save(appVersionInfo);
        return AppVersionInfoController.SUCCESS_TIP;
    }
    
    @RequestMapping({ "/delete" })
    @ResponseBody
    public Object delete(@RequestParam final String id) {
        this.appVersionInfoService.removeById((Serializable)id);
        return AppVersionInfoController.SUCCESS_TIP;
    }
    
    @RequestMapping({ "/editItem" })
    @ResponseBody
    public Object update(final AppVersionInfo appVersionInfo) {
        this.appVersionInfoService.updateById(appVersionInfo);
        return AppVersionInfoController.SUCCESS_TIP;
    }
    
    @RequestMapping(value = { "/delItems" }, method = { RequestMethod.POST })
    @ResponseBody
    public Object delItem(@RequestBody final String[] ids) {
        this.appVersionInfoService.removeByIds((Collection)Arrays.asList(ids));
        return AppVersionInfoController.SUCCESS_TIP;
    }
    
    @RequestMapping({ "/show" })
    public Object show(final String id, final Model model) {
        final AppVersionInfo appVersionInfo = (AppVersionInfo)this.appVersionInfoService.getById((Serializable)id);
        final Map map = BeanUtil.beanToMap(appVersionInfo);
        model.addAttribute("appVersionInfo", new AppVersionInfoWrapper(map).wrap());
        return this.PREFIX + "appVersionInfo_show.html";
    }
}
